package com.xuan.juc.lock;

import java.util.concurrent.TimeUnit;

public class Test {
    public static void main(String[] args) {

        SpinLockTest lock = new SpinLockTest();

        new Thread(()->{
            lock.myLock();

            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally {
                lock.myUnLock();
            }

        },"A").start();

        new Thread(()->{
            lock.myLock();

            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally {
                lock.myUnLock();
            }

        },"B").start();
    }
}
